import React, { useEffect, useState } from 'react';
import Item from '../components/Item'
import axios from 'axios'
import { useNavigate } from 'react-router-dom'
const Index = () => {
    const [hots, setHots] = useState([])
    const getHots = async () => {
        var res = await axios.get('http://122.112.161.135:3000/top/playlist/highquality')
        setHots(res.data.playlists)
    }
    const [news, setNews] = useState([])
    const getNews = async () => {
        var res = await axios.get('http://122.112.161.135:3000/album/newest')
        setNews(res.data.albums)
    }
    const [djs, setDjs] = useState([])
    const getDjs = async () => {
        var res = await axios.get('http://122.112.161.135:3000/personalized/djprogram')
        setDjs(res.data.result)
    }
    useEffect(() => {
        getHots()
        getNews()
        getDjs()
    }, []);
    return (
        <div>
            <Item title={'热门歌曲'} arr={hots.slice(0,3)}></Item>
            <Item title={'最新音乐'} arr={news.slice(0,3)}></Item>
            <Item title={'主播电台'} arr={djs.slice(0,3)}></Item>
        </div>
    );
}

export default Index;
